/**

This file is part of MaCI/GIMnet.

MaCI/GIMnet is free software: you can redistribute it and/or modify it 
under the terms of the GNU Lesser General Public License as published 
by the Free Software Foundation, either version 3 of the License, or 
(at your option) any later version.

MaCI/GIMnet is distributed in the hope that it will be useful, but WITHOUT 
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public 
License for more details.

You should have received a copy of the GNU Lesser General Public 
License along with GIMnet. (See COPYING.LESSER) If not, see 
<http://www.gnu.org/licenses/>.

**/
/**
 * $Id: BearingTypes.hpp,v 1.7 2009-11-14 15:14:45 ray Exp $
 *
 * \file
 * \brief Types for a Bearing interface.
 * \author Mikko Elomaa <mikko.elomaa@tkk.fi>
 *
 */
#ifndef _MACI_BEARINGTYPES_HPP_
#define _MACI_BEARINGTYPES_HPP_
#include <inttypes.h>
#include "ownutils.h"
#include "owndebug.h"

namespace MaCI {

  /** MaCI - Bearing interface.
   *
   * This namespace contains all the methods and types related
   * to the Bearing interface.
   */
  namespace Bearing {
    
    /** Enumeration types for Bearing data elements.
     */
    enum EBearingType { 
      KTypeUnknown               = -1, ///< Unkown type.
      KTypeTimestamp             = 1,  ///< Common::TTimestamp element.
      KTypeCommand               = 2,  ///< TCommand element.
      KTypeHeader                = 3,   ///< THeader element.
      KTypeTargetID              = 4,   ///< TTargetID element.
      KTypeBearing               = 5,   ///< TBearing element.
      KTypeBlock                 = 6,   ///< TBlock element.
      KTypeBearingEvent          = 7,   ///< TBearingEvent element.
      KTypeTriBlock              = 8   ///< TBlock element.
    };
    
    
    /** Enumerations for Bearing Command.
     */
    enum EBearingCommand { 
      KCommandUnknown = 0,
      KCommandScan = 1,
      KCommandMeasure  = 2,
      KCommandGetTags = 3,
      KCommandRead  = 4,
      KCommandWrite  = 5,
      KCommandGetParam = 6,
      KCommandSetParam = 7
    };


    /** Recharger event predefined types.
     */
    enum EBearingEventType { 
      KEventTypeUnknown          = 0,   /// Unknown event type.
      KEventBearingAngle         = 1,   /// Bearing angle measurement
      KEventOperationFailed      = 2,   /// No target was detected
      KEventIDupdate             = 3   /// New ID detected
    };


    /** Bearing command.
     *
     * This structure contains command field to be used when sending
     * action requests to Bearing enabled clients.
     *
     * \see EBearingCommand
     */
    struct TCommand
    {
      TCommand(const uint32_t aCmd = 0) 
	: cmd(aCmd) {}
      uint32_t cmd;             ///< Command

    };


    /*
    struct THeader 
    {
      THeader(const uint32_t aCmd = 0,
               const uint32_t aData = 0) 
	: cmd(aCmd),
          data(aData) {}
      uint32_t cmd;             ///< Command
      uint32_t data;            ///< Data for command. (Is command specific)
    };


    */


    
    /** Bearing data block.
     *
     * This structure contains one data block
     * 
     */
    struct TTriBlock 
    {
      TTriBlock(const uint32_t aDataA = 0,
                const uint32_t aDataB = 0,
                const uint32_t aDataC = 0)
	: dataA(aDataA),
          dataB(aDataB), 
          dataC(aDataC) {}
      uint32_t dataA;             ///< Data block
      uint32_t dataB;             ///< Data block
      uint32_t dataC;             ///< Data block
    };

    struct TBlock 
    {
      TBlock(const uint32_t aData = 0)
	: data(aData) {}
      uint32_t data;             ///< Data block
    };




    /** Bearing event.
     *
     * This structure contains event data for a Bearing event.
     */
    struct TBearingEvent {
      TBearingEvent(const unsigned int aEventType = KEventTypeUnknown,
                      const unsigned int aData = 0)
        : type(aEventType),
          data(aData) {}
      
      uint32_t type;     ///< Event type. See type EBearingEventType.
      uint32_t data;     ///< Some data.
    };


  }
}

#endif
